<template>
    <el-card class="box-card" width="100%">
  <div slot="header" class="clearfix">
    <span>历史模型详情</span>
    <el-button style="float: right; padding: 1px 0; height: 35px; width: 55px" type="primary" @click="goBack()">返回</el-button>
  </div>
  <div class="forms">
    <el-form ref="detailData" :rules="rules" :model="detailData" label-width="100px" class="model-form">
      <el-form-item label="模型id:" prop="id">
        <el-input v-model="detailData.id" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="模型名称：" prop="name">
        <el-input v-model="detailData.name" disabled></el-input>
      </el-form-item>
      <el-form-item label="模型类型：" prop="model_type">
        <el-input v-model="detailData.model_type" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="模型文件名：" prop="model_file_name" v-show="detailData.model_type!=='py'">
        <el-input v-model="detailData.model_file_name" disabled ></el-input>
      </el-form-item>
      <el-form-item label="模型类名：" prop="model_class">
        <el-input v-model="detailData.model_class" disabled></el-input>
      </el-form-item>
      <el-form-item label="模型依赖：" prop="dependencies">
        <el-input v-model="detailData.dependencies" disabled></el-input>
      </el-form-item>
      <el-form-item label="版本：" prop="commit_id">
        <el-input v-model="detailData.commit_id" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="创建者：" prop="user_id">
        <el-input v-model="detailData.user_id" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="创建时间：" prop="create_date">
        <el-input v-model="detailData.create_date" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="是否公有：" prop="public">
        <el-input v-model="detailData.public" disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="模型内容：" prop="model_file_bytes" v-show="detailData.model_type==='py'">
        <el-input v-model="detailData.model_file_bytes" type="textarea" :rows="8" disabled></el-input>
      </el-form-item>
      <el-form-item label="描述：" prop="description">
        <el-input v-model="detailData.description" type="textarea" :rows="5" maxlength=500 disabled></el-input>
      </el-form-item>
      <!-- <el-form-item>
        <el-button type="primary" @click="editModelProcess()" :disabled="role>=3">保存编辑</el-button>
      </el-form-item> -->
    </el-form>
    <!-- 数据集id: {{detailData.id}} -->
  </div>
</el-card>
</template>
<style scoped>
  .forms {
    font-size: 16px;
    text-align: left;
    margin-left: 1px;
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 100%;
  }

  .el-card__header {
    padding: 18px 20px;
    background-color: rgb(238, 241, 246);
  }

  .model-form {
    width: 90%;
    margin: 10px; /* 上下间距160px，左右自动居中*/
    background-color: rgb(255, 255, 255, 0.8); /* 透明背景色 */
    padding: 10px;
    border-radius: 20px; /* 圆角 */
  }

  .git-graph {
    padding: 30px;
  }
</style>
<script>
import { getModelCommit } from '@/api/request/model'
import { Base64 } from 'js-base64'
// import store from '@/store/store'
export default {
//   props: ['title'],
  data () {
    return {
      detailData: null,
      role: 3
    //   title: '我创建的数据集'
    }
  },
  methods: {
    update () {
      this.role = this.$route.query.role
      getModelCommit({model_id: this.$route.query.model_id, commit_id: this.$route.query.commit_id}).then(response => {
        this.detailData = response
        this.detailData.model_file_bytes = Base64.decode(this.detailData.model_file_bytes)
      })
    },
    goBack () {
      this.$router.go(-1)
    }
  },
  activated () {
    this.update()
  },
  mounted () {
    // this.update()
    // this.loading = true
    // this.getVersionHistory()
  }
}
</script>
